﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    public class SearchPostDataModel
    {
        HomestayWebDBEntities ent = new HomestayWebDBEntities();

        public List<Post_ResultSearch_View> SearchPost(SearchObject DataParam)
        {
            String temp = String.Empty;
            if (DataParam.HomestaytypeID != null)
            {
                foreach (var str in DataParam.HomestaytypeID)
                {
                    temp = temp + str;
                }
            }
            else
            {
              temp = null;
                
            }
            List<Post_ResultSearch_View> DataSearchList =
                ent.Store_Post_SearchPost(  DataParam.ProvinceID
                                            , DataParam.DistrictID
                                            , DataParam.Housetype
                                            , DataParam.MinPrice
                                            , DataParam.MaxPrice
                                            , DataParam.Pricetype
                                            , DataParam.MinArea
                                            , DataParam.MaxArea
                                            , temp
                                            , DataParam.HasGara
                                            ,DataParam.HasGarden
                                            ,DataParam.HasKitchen
                                            ).ToList<Post_ResultSearch_View>();
            
            return DataSearchList;
        }

        public List<Post_ResultSearch_View> SearchText(String txtSearch)
        {
            List<Post_ResultSearch_View> resultSearchList =
                ent.Store_Post_SearchText(txtSearch).ToList<Post_ResultSearch_View>();
            return resultSearchList;
        }
        public List<Store_Post_SearchText_GetProDisID_Result> GetProDisId (string txtSearch)
        {
            return ent.Store_Post_SearchText_GetProDisID(txtSearch).ToList();
        } 
    }
    public  class SearchObject
    {
        public int ProvinceID { get; set; }
        public int? DistrictID { get; set; }
        public int? Housetype { get; set; }
        public int Pricetype { get; set; }
        public int MinPrice { get; set; }
        public int MaxPrice { get; set; }
        public int MinArea { get; set; }
        public int MaxArea { get; set; }
        
        public string[] HomestaytypeID { get; set; }
        public bool HasGara { get; set; }
        public bool HasGarden { get; set; }
        public bool HasKitchen { get; set; }
    }
}
